package com.bluesky.daoImpl;

import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;

import com.bluesky.dao.UserDao;
import com.bluesky.model.Admin;
import com.bluesky.model.Pages;
import com.bluesky.model.User;

 public class  UserDaoImpl extends SqlSessionDaoSupport implements UserDao{
	 
	public int AddUser(User user) {
		return this.getSqlSession().insert("com.bluesky.model.User.Adduser",user);
		
	}
	

	public int DeletUserById(int uid) {
		return this.getSqlSession().delete("com.bluesky.model.deletByid", uid);
	}

	public int UpdateUserById(User user) {

		return this.getSqlSession().update("com.bluesky.model.updateuser", user);
	}

	public List<User> getUsersAll() {
		return this.getSqlSession().selectList("com.bluesky.model.getuserall");
	}
	public List<User> getUserByid(int id) {

		return this.getSqlSession().selectList("com.bluesky.model.getuserbyid", id);
	}

	public List<User> getUserBynamePawd(User user) {

		return this.getSqlSession().selectList("com.bluesky.model.getBynamePwd", user);
	}

	public List<User> getUserPage(Pages pages) {
		
		return this.getSqlSession().selectList("com.bluesky.model.getUserBypage", pages);
	}

	public List<User> getUserBySno(String sno) {
		return this.getSqlSession().selectList("com.bluesky.model.getbysno",sno);
	}

	public User getByNamePwd(User user) {
		
		return (User) this.getSqlSession().selectOne("com.com.bluesky.model.getuserbynamepwd",user);
	}
	
	public List<User> getByUserAnd(User user) {
		return  this.getSqlSession().selectList("com.com.bluesky.model.getuserbyand", user);
	}

	public List<User> getAdminBynamePwd(Admin admin) {
		return this.getSqlSession().selectList("com.bluesky.model.Admin.getBynamepwd", admin);
	}

	public List<User> getUserByClassname(String classname) {
		return this.getSqlSession().selectList("com.bluesky.model.Admin.ugetuserbyclassname", classname);
	}

}
